<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
	<title>公共平台 </title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<!-- 样式文件的引入 -->
	<link href="../../../commons/css/style.css" rel="stylesheet" type="text/css"/>
	<link rel="stylesheet" type="text/css" href="../../../commons/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="../../../commons/themes/icon.css">
	<!-- jqueryUI JS文件的引入 -->
	<script type="text/javascript" src="../../../commons/js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" src="../../../commons/js/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../../commons/js/easyui-extends-validate.js"></script>
	<!-- jqueryUI国际化 -->
	<script type="text/javascript" src="../../../commons/js/easyui-lang-zh_CN.js"></script>
	<!-- 开发使用的公用js方法 -->
	<script type="text/javascript" src="../../../commons/js/common.js"></script>
	<!-- 开发国际化的引用，主要完成后台信息在前台提示的国际化，一定要放在最后 -->
	<script type="text/javascript">var ctx = '/comm-work-flow-business';var actionExt = "action";var i18n = new Object();</script>
	<script src="../../../commons/js/i18n/message_zh_CN.js" type="text/javascript"></script>
	<script>
		function openSelWorkFlow(){
			$("#selWorkFlowDialog").dialog('open');
		}
		function openSelModule(){
			$("#selModuleDialog").dialog('open');
		}
		function openSelDept(){
			$("#selDeptDialog").dialog('open');
		}
		function getSelectDeptNode(){
			var nodeDepts = $('#deptTable').datagrid('getSelections');
			if (nodeDepts.length == 0) {
				$.messager.alert('提示','请选择单位','error');
				return;
			}
			$('#deptId').val(nodeDepts[0].id);
			$('#selDeptName').html(nodeDepts[0].name);
			$('#selDeptDialog').dialog('close');
		}
		function getSelectWorkFlowNode(){
			var nodeDepts = $('#deptTable').datagrid('getSelections');
			if (nodeDepts.length == 0) {
				$.messager.alert('提示','请选择单位','error');
				return;
			}
			var nodeModules = $('#moduleTable').datagrid('getSelections');
			if (nodeModules.length == 0) {
				$.messager.alert('提示','请选择业务类型','error');
				return;
			}
			var nodeFlows = $('#workFlowTable').datagrid('getSelections');
			if (nodeFlows.length == 0) {
				$.messager.alert('提示','请选择流程','error');
				return;
			}
			$('#workFlowId').val(nodeFlows[0].id);
			$('#selWorkFlowName').html(nodeFlows[0].workFlowName);
			$('#selWorkFlowDialog').dialog('close');
		}
		function getSelectModuleNode(){
			var nodeDepts = $('#deptTable').datagrid('getSelections');
			if (nodeDepts.length == 0) {
				$.messager.alert('提示','请选择单位','error');
				return;
			}
			var nodeModules = $('#moduleTable').datagrid('getSelections');
			if (nodeModules.length == 0) {
				$.messager.alert('提示','请选择业务类型','error');
				return;
			}
			$('#moduleId').val(nodeModules[0].id);
			$('#selModuleName').html(nodeModules[0].mouldName);
			$('#selModuleDialog').dialog('close');
		}
		function saveModuleNode(){
			var nodeDepts = $('#deptTable').datagrid('getSelections');
			if (nodeDepts.length == 0) {
				$.messager.alert('提示','请选择单位','error');
				return;
			}
			var nodeModules = $('#moduleTable').datagrid('getSelections');
			if (nodeModules.length == 0) {
				$.messager.alert('提示','请选择业务类型','error');
				return;
			}
			var nodeFlows = $('#workFlowTable').datagrid('getSelections');
			if (nodeFlows.length == 0) {
				$.messager.alert('提示','请选择流程','error');
				return;
			}
			var deptId = nodeDepts[0].id;
			var moduleId = nodeModules[0].id;
			var workFlowId = nodeFlows[0].id;
			$.ajax({
				type: "get",
				timeout:20000,
				url:  "/human-manage/workFlowAnt/bindWorkFlowId/"+ deptId + "/" + moduleId + "/" + workFlowId,
				success: function(data,res){
					if (data.success) {
						$.messager.alert('提示','流程绑定成功！','info');
					}
				},
				error: function(res){
					$.messager.alert('提示','流程绑定出现了异常！','error');
				}
			});
		}
	</script>
  </head>
  <body>
  	<div id="showApplyDialog"></div>
  	<input type="hidden" name="workFlowId" id="workFlowId"/>
  	<input type="hidden" name="moduleId" id="moduleId"/>
  	<input type="hidden" name="deptId" id="deptId"/>
  	<div id="selWorkFlowDialog" class="easyui-dialog" title="选择工作流" style="width:320px;height:382px;padding:0px;padding-top: 0px;" 
			data-options="iconCls: 'icon-flow',method:'get',closed:true,modal: true,
			buttons: [{	text:'保存',	iconCls:'icon-ok',	handler:function(){getSelectWorkFlowNode();	}},
			{	text:'取消',	iconCls:'icon-cancel',	handler:function(){		$('#selWorkFlowDialog').dialog('close');	}}]">
			<table id="workFlowTable" class="easyui-datagrid" style="width:100%;height:auto"
					data-options="
						iconCls: 'icon-edit',
						singleSelect:true,
						method:'get',
						pagination:false,
						fit:true,border:false,
						url:'/human-manage/workFlowAnt/getWorkFlowTemplates'
					">
				<thead>
					<tr>
						<th data-options="field:'id',width:20,checkbox:true"> </th>
						<th data-options="field:'workFlowName',width:138">流程名称</th>
						<th data-options="field:'updateName',width:140">更新者</th>
					</tr>
				</thead>
			</table>
		</div>
		<div id="selModuleDialog" class="easyui-dialog" title="选择业务类型" style="width:320px;height:382px;padding:0px;padding-top: 0px;" 
			data-options="iconCls: 'icon-flow',method:'get',closed:true,modal: true,
			buttons: [{	text:'保存',	iconCls:'icon-ok',	handler:function(){getSelectModuleNode();	}},
			{	text:'取消',	iconCls:'icon-cancel',	handler:function(){		$('#selModuleDialog').dialog('close');	}}]">
			<table id="moduleTable" class="easyui-datagrid" style="width:100%;height:auto"
					data-options="
						iconCls: 'icon-edit',
						singleSelect:true,
						method:'get',
						pagination:false,
						fit:true,border:false,
						url:'/human-manage/workFlowAnt/getMouldInfoList'
					">
				<thead>
					<tr>
						<th data-options="field:'id',width:20,checkbox:true"> </th>
						<th data-options="field:'mouldName',width:138">模板名称</th>
						<th data-options="field:'tabName',width:140">关联表</th>
					</tr>
				</thead>
			</table>
		</div>
		<div id="selDeptDialog" class="easyui-dialog" title="选择单位" style="width:320px;height:382px;padding:0px;padding-top: 0px;" 
			data-options="iconCls: 'icon-flow',method:'get',closed:true,modal: true,
			buttons: [{	text:'保存',	iconCls:'icon-ok',	handler:function(){getSelectDeptNode();	}},
			{	text:'取消',	iconCls:'icon-cancel',	handler:function(){		$('#selDeptDialog').dialog('close');	}}]">
			<table id="deptTable" class="easyui-datagrid" style="width:100%;height:auto"
					data-options="
						iconCls: 'icon-edit',
						singleSelect:true,
						method:'get',
						pagination:false,
						fit:true,border:false,
						url:'/human-manage/workFlowAnt/getWorkFlowUnits'
					">
				<thead>
					<tr>
						<th data-options="field:'id',width:20,checkbox:true"> </th>
						<th data-options="field:'name',width:238">单位名称</th>
					</tr>
				</thead>
			</table>
		</div>
    <table width="100%" style="margin-top: 20px;">
    	<tr>
    		<td><a href="javascript:void(0);"><div style="text-align: center;"><img src="../../../commons/images/sailor.png"/></div><div style="text-align: center;padding-top: 6px;">1-绑定单位</div></a>
			<br/><div style="text-align: center;"><a href="javascript:openSelDept();" class="easyui-linkbutton" data-options="iconCls:'icon-flow'">绑定单位</a></div><br/>
			<div id="selDeptName" style="text-align: center;">未选择单位</div></td>
    		<td><a href="javascript:void(0);"><div style="text-align: center;"><img src="../../../commons/images/sailor.png"/></div><div style="text-align: center;padding-top: 6px;">2-绑定业务类型</div></a>
    		<br/><div style="text-align: center;"><a href="javascript:openSelModule();" class="easyui-linkbutton" data-options="iconCls:'icon-flow'">绑定业务类型</a></div><br/>
    		<div id="selModuleName" style="text-align: center;">未选择业务类型</div></td>
    		<td><a href="javascript:void(0);"><div style="text-align: center;"><img src="../../../commons/images/sailor.png"/></div><div style="text-align: center;padding-top: 6px;">3-绑定流程</div></a>
			<br/><div style="text-align: center;"><a href="javascript:openSelWorkFlow();" class="easyui-linkbutton" data-options="iconCls:'icon-flow'">绑定工作流</a></div><br/>
			<div id="selWorkFlowName" style="text-align: center;">未选择工作流</div></td>
			<br/><br/><br/><br/>
			<div style="text-align: center;"><a href="javascript:saveModuleNode();;" class="easyui-linkbutton" data-options="iconCls:'icon-flow'">提交</a></div><br/>
    	</tr>
    </table>
  </body>
</html>
